﻿using System.Web.Mvc;

namespace ExtendedMvc {
	/// <summary>
	/// Used by the view engine to render a strongly typed  view as a Web Forms page.
	/// </summary>
	/// <typeparam name="TModel">The type of the model.</typeparam>
	public class ModelViewPage<TModel> : ViewPage<TModel>, IViewDataContainer<TModel> where TModel : class {
		protected string _htmlNamePrefix;

		/// <summary>
		/// Initializes a new instance of the <see cref="ModelViewPage&lt;TModel&gt;"/> class.
		/// </summary>
		public ModelViewPage() : base() { }

		/// <summary>
		/// Initializes a new instance of the <see cref="ModelViewPage&lt;TModel&gt;"/> class.
		/// </summary>
		/// <param name="htmlNamePrefix">The HTML name prefix.</param>
		public ModelViewPage(string htmlNamePrefix)
			: this() {
			this._htmlNamePrefix = htmlNamePrefix;
		}

		/// <summary>
		/// Gets or sets the HTML name prefix.
		/// </summary>
		/// <value>The HTML name prefix.</value>
		public string HtmlNamePrefix {
			get { return _htmlNamePrefix; }
			set { _htmlNamePrefix = value; }
		}

		/// <summary>
		/// Gets the HTML.
		/// </summary>
		/// <value>The HTML.</value>
		public new ModelViewHtmlHelper<TModel> Html { get { return new ModelViewHtmlHelper<TModel>(this, this.ViewContext); } }

		/// <summary>
		/// Gets the ajax.
		/// </summary>
		/// <value>The ajax.</value>
		public new ModelViewAjaxHelper<TModel> Ajax { get { return new ModelViewAjaxHelper<TModel>(this, this.ViewContext); } }
	}

	/// <summary>
	/// Used by the view engine to render a strongly typed  view as a Web Forms page.
	/// </summary>
	/// <typeparam name="TModel">The type of the model.</typeparam>
	public class ModelViewPage : ViewPage, IViewDataContainer {
		protected string _htmlNamePrefix;

		/// <summary>
		/// Initializes a new instance of the <see cref="ModelViewPage&lt;TModel&gt;"/> class.
		/// </summary>
		public ModelViewPage() : base() { }

		/// <summary>
		/// Initializes a new instance of the <see cref="ModelViewPage&lt;TModel&gt;"/> class.
		/// </summary>
		/// <param name="htmlNamePrefix">The HTML name prefix.</param>
		public ModelViewPage(string htmlNamePrefix)
			: this() {
			this._htmlNamePrefix = htmlNamePrefix;
		}

		/// <summary>
		/// Gets or sets the HTML name prefix.
		/// </summary>
		/// <value>The HTML name prefix.</value>
		public string HtmlNamePrefix {
			get { return _htmlNamePrefix; }
			set { _htmlNamePrefix = value; }
		}

		/// <summary>
		/// Gets the HTML.
		/// </summary>
		/// <value>The HTML.</value>
		public new ModelViewHtmlHelper Html { get { return new ModelViewHtmlHelper(this, this.ViewContext); } }

		/// <summary>
		/// Gets the ajax.
		/// </summary>
		/// <value>The ajax.</value>
		public new ModelViewAjaxHelper Ajax { get { return new ModelViewAjaxHelper(this, this.ViewContext); } }
	}
}
